# Contributor: Róbert Nagy <vrnagy@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libcec-rpi
pkgver=6.0.2
pkgrel=3
pkgdesc="libcec for the Pulse-Eight USB-CEC adapter for the Raspberry Pi"
url="https://github.com/Pulse-Eight/libcec"
arch="armhf armv7 aarch64" # Only Raspberry Pi platforms
license="GPL-2.0-or-later"
depends_dev="
	eudev-dev
	libxrandr-dev
	python3-dev
	swig
	"
makedepends="$depends_dev
	cmake
	p8-platform-dev
	raspberrypi-libs
	raspberrypi-dev
	samurai
	"
subpackages="$pkgname-dev py3-$pkgname:py3"
source="https://github.com/Pulse-Eight/libcec/archive/libcec-$pkgver.tar.gz
	fix-null-return.patch
	"
provides="libcec=$pkgver-r$pkgrel"

builddir="$srcdir"/libcec-libcec-$pkgver

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DBUILD_SHARED_LIBS=1 \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib \
		-DCMAKE_INSTALL_LIBDIR_NOARCH=/usr/lib \
		-DHAVE_EXYNOS_API=0 \
		-DHAVE_RPI_API=1 \
		-DRPI_INCLUDE_DIR=/opt/vc/include \
		-DRPI_LIB_DIR=/opt/vc/lib
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

py3() {
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/python* "$subpkgdir"/usr/lib/
}

sha512sums="
c16ac268e67b01d4e35fad644e5927e1d9fc7bcaeff698ac5f0eadd31ec63a0bef2a2b2bc37860d1571e1e0cdc55911c2de468c661c7c7ae1d492f80188035cb  libcec-6.0.2.tar.gz
0aa63e622ecf3d9009efc06db801c7a5558aa30a0543701e2e12bf052a54155240fc2d2bf339aab1af7288c3e85c7edf5087e4de6ce800398fba05897cf6d22f  fix-null-return.patch
"
